﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;

using CloudSoft.Workflows;

namespace ERPStore.NewsLetters.Workflows.Activities
{

	public sealed class GetPendingItemList : CodeActivity
	{
		public InArgument<Models.Settings> Settings { get; set; }
		public OutArgument<IList<Models.PendingItem>> PendingItemList { get; set; }

		protected override void Execute(CodeActivityContext context)
		{
			var settings = context.GetValue(this.Settings);
			var newsLettersService = context.GetService<Services.NewsLettersService>();

			var list = newsLettersService.GetPendingItemList(settings.PageSize);
			if (list == null)
			{
				list = new List<Models.PendingItem>();
			}

			context.SetValue(PendingItemList, list);
		}
	}
}
